{% include 'admin/header.html' %}

<body>
  <div class="lyear-layout-web">
    <div class="lyear-layout-container">
      {% include 'admin/nav.html' %}

      <main class="lyear-layout-content">
        <div class="container-fluid">
          <!-- 提示信息 -->
          <div class="alert alert-info alert-dismissible fade show" role="alert">
            <i class="fas fa-info-circle mr-2"></i>
            请更新宿舍信息并保存。

          </div>

          <!-- 卡片标题部分 -->
          <div class="card shadow-lg mb-4">
            <header class="card-header d-flex justify-content-between align-items-center">
              <h4 class="card-title mb-0 text-primary">编辑宿舍</h4>
              <div>
                <a href="{{ url_for('main.dorm_list') }}" class="btn btn-outline-primary btn-sm">返回宿舍列表</a>
              </div>
            </header>

            <!-- 卡片内容部分 -->
            <div class="card-body">
              <form action="{{ url_for('main.edit_dorm', id=dorm.id) }}" method="POST">
                <div class="form-group mb-3">
                  <label for="dorm_typeid">宿舍类型</label>
                  <select id="dorm_typeid" name="dorm_typeid" class="form-control">
                    {% for dorm_type in dorm_types %}
                    <option value="{{ dorm_type.id }}" {% if dorm.dorm_typeid == dorm_type.id %}selected{% endif %}>
                      {{ dorm_type.name }}
                    </option>
                    {% endfor %}
                  </select>
                </div>

                <div class="form-group mb-3">
                  <label for="name">宿舍名称</label>
                  <input type="text" id="name" name="name" class="form-control" value="{{ dorm.name }}" required>
                </div>

                <div class="form-group mb-3">
                  <label for="bed_count">床位数</label>
                  <input type="number" id="bed_count" name="bed_count" class="form-control" value="{{ dorm.bed_count }}" required>
                </div>
                <div class="d-flex justify-content-between">
                <button type="submit" class="btn btn-success">保存修改</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </main>
    </div>
  </div>

{% include 'admin/footer.html' %}
</body>
